home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / rstorbx.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  2.1 KB  |  77 lines

  1. ;void  restore_box(box,top_x,top_y,width,depth);
  2. ;  unsigned char  *box,top_x,top_y,width,depth;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  9.     ASSUME  CS:_TEXT
  10.     PUBLIC _restore_box
  11. _restore_box proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    mov  bl,_snow_protect    ;grab _snow_protect
  21.     push ds            ;save DS
  22.     cld            ;set direction flag
  23.     mov  ax,_video_buffer    ;fetch video address
  24.     mov  es,ax        ;ES points to screen
  25.     cmp  _memory_model,2    ;data near or far?
  26.     jb   L0            ;jump if near
  27.     lds  si,dword ptr[bp+4] ;DS:SI pts to byte array
  28.     add  bp,2        ;forward BP since dword ptr
  29.     jmp  short L00        ;jump ahead
  30. L0:    mov  si,[bp+4]        ;NEAR case
  31. L00:    mov  [bp+4],bl        ;save _snow_protect on stack
  32.     sub  ax,ax        ;
  33.     mov  al,[bp+8]        ;row in AX
  34.     dec  ax            ;count rows from 0
  35.     mov  dl,160        ;160 bytes per row
  36.     mul  dl            ;AX times 160
  37.     sub  dx,dx        ;
  38.     mov  dl,[bp+6]        ;col in DX
  39.     dec  dx            ;count cols from 0
  40.     shl  dx,1        ;double for attributes
  41.     add  ax,dx        ;offset of topleft corner
  42.     mov  bx,ax        ;move scrn ptr to BX
  43.     mov  dh,[bp+10]        ;width in BX
  44.     mov  dl,[bp+12]        ;depth in DX
  45.     sub  cx,cx        ;clear CX
  46. L1:    mov  di,bx        ;set ES:DI scrn ptr
  47.     mov  cl,dh        ;width counter
  48.     push dx            ;save width,depth ctrs
  49. L2:    cmp  byte ptr[bp+4],0    ;protect against snow?
  50.     je   L5            ;jump ahead if not
  51.     mov  dx,3dah        ;status byte address
  52. L3:    in   al,dx        ;get status byte
  53.     test al,1        ;test bit
  54.     jnz  L3            ;loop till 0
  55.     cli            ;disable interrupts
  56. L4:    in   al,dx        ;get status byte
  57.     test al,1        ;test bit
  58.     jz   L4            ;loop till 1
  59. L5:    movsw            ;transfer char to scrn
  60.     loop L2            ;go do next in row
  61.     pop  dx            ;restore width,depth ctrs
  62.     add  bx,160        ;forward ptr to next row
  63.     dec  dl            ;dec depth counter
  64.     jnz  L1            ;loop if another line
  65. L6:    sti            ;reenable interrupts
  66.     pop  ds            ;
  67.     pop  si            ;
  68.     pop  di            ;
  69.     pop  bp            ;
  70.     cmp  _memory_model,0    ;quit
  71.     jle  quit        ;
  72.     db   0CBh        ;RET far
  73. quit:    ret            ;RET near
  74. _restore_box endp
  75. _TEXT    ENDS
  76.     END
  77.